<!-- 我联系的楼宇 -->
<template>
  <div>
    <ContainerTitle text="我联系的楼宇" class="title"></ContainerTitle>
    <div class="msgDiv" v-if="total != 0">
      <el-table
        :data="tableData"
        
        min-height="400"
        :border="true"
        :header-cell-style="{ background: '#F4F4F4',color: '#045DB9' }"
      >
        <el-table-column type="index" label="序号" width="50">
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">{{((currentPage - 1) * pageSize) + (scope.$index + 1)}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="buildingName" label="楼宇名称" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ scope.row.buildingName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="所属街道" width="120">
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ $selectDict(Street, scope.row.streetCode).dictLabel }}
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="address" label="详细位置" width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ scope.row.address }}
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="applyTime" label="申请时间" width="160">
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ scope.row.applyTime }}
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="contactsPerson" label="联系人" width="120" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ scope.row.contactsPerson }}
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="contactsPhone" label="联系方式" width="110">
          <template slot-scope="scope">
            <div class="_buildingName" @click="tobuilding(scope.row.buildingInfoId)">
              {{ scope.row.contactsPhone }}
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[5, 10, 15, 20, 25, 30]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
    <div class="msgDivBox" v-if="total == 0">
      <div>您还未申请入驻过楼宇，到招商中心寻找适合自己企业的楼宇吧!</div>
      <Buttons :buttons="buttons" @jump="$router.push({ name: 'investment' })" class="btn"></Buttons>
      <!-- <div class="btn" @click="$router.push({ name: 'investment' })">
        随便看看
      </div> -->
    </div>
  </div>
</template>

<script>
import { getMyIntendedBuildings } from '@/common/api/company.js'
export default {
  data() {
    //这里存放数据
    return {
      buttons:[{ text: "随便看看", type: "success", size: "l", method: "jump" }],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      Street: {},
      crumbs: [
        {
          label: "企业空间",
          value: "company",
        },
        {
          label: "招商中心",
          value: "investment",
          // choose: true,
        },
        {
          label: "我联系的楼宇",
          value: "investmentContact",
          choose: true,
        },
      ],
      tableData: [],
    };
  },
  methods: {
    tobuilding(id) {
      this.$router.push(`/investment/investmentdetails?id=${id}`)
    },
    async getMessage() {
      let res = await getMyIntendedBuildings({ pageSize: this.pageSize, pageNum: this.currentPage })
      if (res.code == 200) {
        this.tableData = res.rows;
        this.total = res.total;
      }
    },
    // 字典
    async getDict() {
      // 调用公共方法中的查询字典表
      this.getDictList(this,`street_code`).then(res => {
        this.Street = res.street_code;
      })
    },
    // 分页
    handleSizeChange(val) {
      this.pageSize = val;
      this.getMessage();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getMessage();
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.getDict();
    this.getMessage();
  },
};
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
.title{
  margin-bottom: 5px;
}
._buildingName{
  // color:#045db9;
  cursor: pointer; 
}
.breadcrumb {
  width: 1000px;
  margin: 20px 0;
}

.roomDiv {
  display: flex;
  justify-content: center;
}

.roomDiv .leftDiv {
  width: 200px;
  text-align: left;
}

.roomDiv .rightDiv {
  margin-top: 14px;
  width: 800px;
  margin-left: 30px;
}

.titleDiv {
  border-bottom: 2px solid #045db9;
  text-align: left;
  padding: 10px;
  font-size: 20px;
  font-weight: bold;
  color: #045db9;
  margin-bottom: 20px;
}

.msgDiv {
  margin: 40px 0;
}

.block {
  margin-top: 14px;
  text-align: right;
}
.rowBtn {
  cursor: pointer;
  margin-right: 12px;
}

.toLoginBtn {
  color: #ffffff;
  background-color: #045db9;
  padding: 10px 40px;
  display: inline-block;
  font-size: 15px;
  border-radius: 5px;
  transition: all 0.2s ease 0s;
}

.toLoginBtn:hover {
  cursor: pointer;
  box-shadow: 0px 0px 5px #eeeeee;
}

.layout {
  min-height: 100vh;
  position: relative;
  padding-bottom: 150px;
  box-sizing: border-box;
}

.msgDivBox {
  height: 180px;
  text-align: center;
  background: #ffffff;
  border: 1px solid #cccccc;
  font-size: 18px;
  color: #595e64;
  padding-top: 41px;
}

.btn {
  width: 120px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 14px;
  background: #045db9;
  border-radius: 3px;
  color: #ffffff;
  margin: 56px auto 0;
  cursor: pointer;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}
</style>